<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: Loki</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: Loki</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Loki<span class="signature">(filename, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="Loki"><span class="type-signature"></span>new Loki<span class="signature">(filename, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Loki: The main database class</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>filename</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>name of the file to be saved to</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) config options object</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>env</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>verbose</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>enable console output</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autosave</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>enables autosave</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autosaveInterval</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    5000
                
                </td>
            

            <td class="description last"><p>time interval (in milliseconds) between saves (if dirty)</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autoload</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>enables autoload on loki instantiation</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autoloadCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>user callback called after database load</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>adapter</code></td>
            

            <td class="type">
            
                
<span class="param-type">adapter</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>an instance of a loki persistence adapter</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>serializationMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    'normal'
                
                </td>
            

            <td class="description last"><p>['normal', 'pretty', 'destructured']</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>destructureDelimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>string delimiter used for destructured serialization</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>throttledSaves</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    true
                
                </td>
            

            <td class="description last"><p>debounces multiple calls to to saveDatabase reducing number of disk I/O operations
                                                and guaranteeing proper serialization of the calls.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    
    <dt class="implements">Implements:</dt>
    <dd class="implements"><ul>
        
            <li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li>
        
    </ul></dd>
    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line764">line 764</a>
    </li></ul></dd>
    

    

    

    
</dl>


















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="addCollection"><span class="type-signature"></span>addCollection<span class="signature">(name, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
    

    



<div class="description">
    <p>Adds a collection to the database.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>name</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>name of collection to add</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(optional) options to configure collection with.</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>unique</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    []
                
                </td>
            

            <td class="description last"><p>array of property names to define unique constraints for</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>exact</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    []
                
                </td>
            

            <td class="description last"><p>array of property names to define exact constraints for</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>indices</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    []
                
                </td>
            

            <td class="description last"><p>array property names to define binary indexes for</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>asyncListeners</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether listeners are called asynchronously</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>disableMeta</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>set to true to disable meta property on documents</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>disableChangesApi</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    true
                
                </td>
            

            <td class="description last"><p>set to false to enable Changes Api</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>disableDeltaChangesApi</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    true
                
                </td>
            

            <td class="description last"><p>set to false to enable Delta Changes API (requires Changes API, forces cloning)</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autoupdate</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>use Object.observe to update objects automatically</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>clone</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>specify whether inserts and queries clone to/from user</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>cloneMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    'parse-stringify'
                
                </td>
            

            <td class="description last"><p>'parse-stringify', 'jquery-extend-deep', 'shallow, 'shallow-assign'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>ttl</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>age of document (in ms.) before document is considered aged/stale.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>ttlInterval</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>time interval for clearing out 'aged' documents; not set by default.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1047">line 1047</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>a reference to the collection which was just added</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Collection.html">Collection</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="clearChanges"><span class="type-signature"></span>clearChanges<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>(Changes API) : clears all the changes in all collections.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1786">line 1786</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="close"><span class="type-signature"></span>close<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Emits the close event. In autosave scenarios, if the database is dirty, this will save and disable timer.
Does not actually destroy the db.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) if supplied will be registered with close event before emitting.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1722">line 1722</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="configureOptions"><span class="type-signature"></span>configureOptions<span class="signature">(options, initialConfig)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Allows reconfiguring database options</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last"><p>configuration options to apply to loki db object</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>env</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>verbose</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>enable console output (default is 'false')</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autosave</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>enables autosave</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autosaveInterval</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            

            

            <td class="description last"><p>time interval (in milliseconds) between saves (if dirty)</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autoload</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>enables autoload on loki instantiation</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>autoloadCallback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>user callback called after database load</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>adapter</code></td>
            

            <td class="type">
            
                
<span class="param-type">adapter</span>


            
            </td>

            

            

            <td class="description last"><p>an instance of a loki persistence adapter</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>serializationMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>['normal', 'pretty', 'destructured']</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>destructureDelimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>string delimiter used for destructured serialization</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>initialConfig</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>(internal) true is passed when loki ctor is invoking</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line905">line 905</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="copy"><span class="type-signature"></span>copy<span class="signature">(options)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Copies 'this' database into a new Loki instance. Object references are shared to make lightweight.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last"><p>apply or override collection level settings</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>removeNonSerializable</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>nulls properties not safe for serialization.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1003">line 1003</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="deleteDatabase"><span class="type-signature"></span>deleteDatabase<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Handles deleting a database from file system, local
   storage, or adapter (indexeddb)
   This method utilizes loki configuration options (if provided) to determine which
   persistence method to use, or environment detection (if configuration was not provided).</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2670">line 2670</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="deserializeCollection"><span class="type-signature"></span>deserializeCollection<span class="signature">(destructuredSource, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {array}</span></h4>
    

    



<div class="description">
    <p>Collection level utility function to deserializes a destructured collection.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>destructuredSource</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>destructured representation of collection to inflate</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>used to describe format of destructuredSource input</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>delimited</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether source is delimited string or an array</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>if delimited, this is delimiter to use (if other than default)</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1520">line 1520</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>an array of documents to attach to collection.data.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">array</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="deserializeDestructured"><span class="type-signature"></span>deserializeDestructured<span class="signature">(destructuredSource, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|array}</span></h4>
    

    



<div class="description">
    <p>Database level destructured JSON deserialization routine to minimize memory overhead.
Internally, Loki supports destructuring via loki &quot;serializationMethod' option and
the optional LokiPartitioningAdapter class. It is also available if you wish to do
your own structured persistence or data exchange.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>destructuredSource</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>destructured json or array to deserialize from</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>source format options</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>partitioned</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether db and each collection are separate</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>partition</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>can be used to deserialize only a single partition</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimited</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    true
                
                </td>
            

            <td class="description last"><p>whether subitems are delimited or subarrays</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>override default delimiter</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1414">line 1414</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>An object representation of the deserialized database, not yet applied to 'this' db or document array</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">object</span>
|

<span class="param-type">array</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="generateChangesNotification"><span class="type-signature"></span>generateChangesNotification<span class="signature">(optional<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {array}</span></h4>
    

    



<div class="description">
    <p>(Changes API) : takes all the changes stored in each
collection and creates a single array for the entire database. If an array of names
of collections is passed then only the included collections will be tracked.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>optional</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>array of collection names. No arg means all collections are processed.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1758">line 1758</a>
    </li></ul></dd>
    

    

    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li>private method createChange() in Collection</li>
        </ul>
    </dd>
    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>array of changes</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">array</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getCollection"><span class="type-signature"></span>getCollection<span class="signature">(collectionName)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
    

    



<div class="description">
    <p>Retrieves reference to a collection by name.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>collectionName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>name of collection to look up</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1091">line 1091</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Reference to collection in database by that name, or null if not found</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Collection.html">Collection</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="listCollections"><span class="type-signature"></span>listCollections<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;object>}</span></h4>
    

    



<div class="description">
    <p>Returns a list of collections in the database.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1128">line 1128</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>array of objects containing 'name', 'type', and 'count' properties.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array.&lt;object></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="loadDatabase"><span class="type-signature"></span>loadDatabase<span class="signature">(options, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Handles manually loading from file system, local storage, or adapter (such as indexeddb)
   This method utilizes loki configuration options (if provided) to determine which
   persistence method to use, or environment detection (if configuration was not provided).
   To avoid contention with any throttledSaves, we will drain the save queue first.</p>
<p>If you are configured with autosave, you do not need to call this method yourself.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>if throttling saves and loads, this controls how we drain save queue before loading</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>recursiveWait</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>(default: true) wait recursively until no saves are queued</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>recursiveWaitLimit</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>(default: false) limit our recursive waiting to a duration</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>recursiveWaitLimitDelay</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            

            

            <td class="description last"><p>(default: 2000) cutoff in ms to stop recursively re-draining</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2529">line 2529</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>db.loadDatabase({}, function(err) {  if (err) {    console.log("error : " + err);  }  else {    console.log("database loaded.");  }});</code></pre>



        
            

    

    
    <h4 class="name" id="loadJSON"><span class="type-signature"></span>loadJSON<span class="signature">(serializedDb, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Inflates a loki database from a serialized JSON string</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>serializedDb</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>a serialized loki database string</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>apply or override collection level settings</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>retainDirtyFlags</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>whether collection dirty flags will be preserved</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1562">line 1562</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="loadJSONObject"><span class="type-signature"></span>loadJSONObject<span class="signature">(dbObject, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Inflates a loki database from a JS object</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>dbObject</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>a serialized loki database string</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>apply or override collection level settings</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>retainDirtyFlags</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>whether collection dirty flags will be preserved</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1587">line 1587</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="removeCollection"><span class="type-signature"></span>removeCollection<span class="signature">(collectionName)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Removes a collection from the database.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>collectionName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>name of collection to remove</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1148">line 1148</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="renameCollection"><span class="type-signature"></span>renameCollection<span class="signature">(oldName, newName)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
    

    



<div class="description">
    <p>Renames an existing loki collection</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>oldName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>name of collection to rename</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>newName</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>new name of collection</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1113">line 1113</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>reference to the newly renamed collection</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Collection.html">Collection</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="saveDatabase"><span class="type-signature"></span>saveDatabase<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Handles manually saving to file system, local storage, or adapter (such as indexeddb)
   This method utilizes loki configuration options (if provided) to determine which
   persistence method to use, or environment detection (if configuration was not provided).</p>
<p>If you are configured with autosave, you do not need to call this method yourself.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2623">line 2623</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>db.saveDatabase(function(err) {  if (err) {    console.log("error : " + err);  }  else {    console.log("database saved.");  }});</code></pre>



        
            

    

    
    <h4 class="name" id="serialize"><span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    <p>Serialize database to a string which can be loaded via <a href="Loki.html#loadJSON">Loki#loadJSON</a></p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1196">line 1196</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Stringified representation of the loki database.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="serializeChanges"><span class="type-signature"></span>serializeChanges<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    

    



<div class="description">
    <p>(Changes API) - stringify changes for network transmission</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1778">line 1778</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>string representation of the changes</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="serializeCollection"><span class="type-signature"></span>serializeCollection<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {string|array}</span></h4>
    

    



<div class="description">
    <p>Collection level utility method to serialize a collection in a 'destructured' format</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>used to determine output of method</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>delimited</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            

            

            <td class="description last"><p>whether to return single delimited string or an array</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>(optional) if delimited, this is delimiter to use</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>collectionIndex</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            

            

            <td class="description last"><p>specify which collection to serialize data for</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1362">line 1362</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A custom, restructured aggregation of independent serializations for a single collection.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>
|

<span class="param-type">array</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="serializeDestructured"><span class="type-signature"></span>serializeDestructured<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {string|array}</span></h4>
    

    



<div class="description">
    <p>Database level destructured JSON serialization routine to allow alternate serialization methods.
Internally, Loki supports destructuring via loki &quot;serializationMethod' option and
the optional LokiPartitioningAdapter class. It is also available if you wish to do
your own structured persistence or data exchange.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>output format options for use externally to loki</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>partitioned</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(default: false) whether db and each collection are separate</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>partition</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>can be used to only output an individual collection or db (-1)</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimited</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(default: true) whether subitems are delimited or subarrays</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delimiter</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>override default delimiter</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1229">line 1229</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A custom, restructured aggregation of independent serializations.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>
|

<span class="param-type">array</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="throttledSaveDrain"><span class="type-signature"></span>throttledSaveDrain<span class="signature">(callback, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Wait for throttledSaves to complete and invoke your callback when drained or duration is met.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>callback to fire when save queue is drained, it is passed a sucess parameter value</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>configuration options</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>recursiveWait</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>(default: true) if after queue is drained, another save was kicked off, wait for it</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>recursiveWaitLimit</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>(default: false) limit our recursive waiting to a duration</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>recursiveWaitLimitDelay</code></td>
            

            <td class="type">
            
                
<span class="param-type">int</span>


            
            </td>

            

            

            <td class="description last"><p>(default: 2000) cutoff in ms to stop recursively re-draining</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2386">line 2386</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Collection.html">Collection</a></li><li><a href="DynamicView.html">DynamicView</a></li><li><a href="Loki.html">Loki</a></li><li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li><li><a href="LokiFsAdapter.html">LokiFsAdapter</a></li><li><a href="LokiFsStructuredAdapter.html">LokiFsStructuredAdapter</a></li><li><a href="LokiIndexedAdapter.html">LokiIndexedAdapter</a></li><li><a href="LokiLocalStorageAdapter.html">LokiLocalStorageAdapter</a></li><li><a href="LokiMemoryAdapter.html">LokiMemoryAdapter</a></li><li><a href="LokiPartitioningAdapter.html">LokiPartitioningAdapter</a></li><li><a href="Resultset.html">Resultset</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-Autoupdating Collections.html">Autoupdating Collections</a></li><li><a href="tutorial-Changes API.html">Changes API</a></li><li><a href="tutorial-Collection Transforms.html">Collection Transforms</a></li><li><a href="tutorial-Indexing and Query performance.html">Indexing and Query performance</a></li><li><a href="tutorial-Loki Angular.html">Loki Angular</a></li><li><a href="tutorial-Persistence Adapters.html">Persistence Adapters</a></li><li><a href="tutorial-Query Examples.html">Query Examples</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu May 10 2018 03:42:33 GMT-0400 (Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>